﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using S4Store.Domain.SellerKpi;
using LX.Web.Excel;

namespace S4Store.Domain.Report
{
    public class SellerCommonReport : ExportObject
    {

        #region 数据导出
        public override bool? Discriminate(string propertyname)
        {
            if (propertyname == "SaleRate" ||
                propertyname=="XLWCD"||
                propertyname == "XLJDC")
            {
                return this.XLJDC >= 0;
            }
            if (propertyname == "LDPCWCD" ||
                propertyname == "LDPCJDC")
            {
                return this.LDPCJDC >= 0;
            }
            if (propertyname == "DJKHWCJD"||
                propertyname=="DJKHJDC")
            {
                return this.DJKHJDC >= 0;
            }
            if (propertyname == "SCLDDJLV")
            {
                return this.SCLDDJLV >= this.SellerPerformanceStandard.SCLDDJLV;
            }
            if (propertyname == "AKXQWZFXLV" )
            {
                return this.AKXQWZFXLV >= this.SellerPerformanceStandard.AKXQWZFXLV;
            }
            if (propertyname == "SCSJLV" )
            {
                return this.SCSJLV >= this.SellerPerformanceStandard.SCSJLV;
            }
            if (propertyname == "SCSJCJLV")
            {
                return this.SCSJCJLV >= this.SellerPerformanceStandard.SCSJCJLV;
            }
            if (propertyname == "STMXBTXLV")
            {
                return this.STMXBTXLV >= this.SellerPerformanceStandard.STMXBGTXLV;
            }
            if (propertyname == "SYKHZHLV")
            {
                return this.SYKHZHLV >= this.SellerPerformanceStandard.SYKHZHLV;
            }
            if (propertyname == "DYDJKHCJLV")
            {
                return this.DYDJKHCJLV >= this.SellerPerformanceStandard.DJKHCJLV;
            }
            if (propertyname == "DDJCZHLV")
            {
                return this.DDJCZHLV >= this.SellerPerformanceStandard.DDJCZHLV;
            }

            if (propertyname == "CXJGCJLV")
            {
                return this.CXJGCJLV >= this.SellerPerformanceStandard.CXJGCJLV;
            }
            if (propertyname == "ESCPGLV")
            {
                return this.ESCPGLV >= this.SellerPerformanceStandard.ESCPGLV;
            }
            if (propertyname == "ZHLV")
            {
                return this.ZHLVDiff >= 0;
            }
            if (propertyname == "BXLV")
            {
                return this.BXLVDiff>=0;
            }
            if (propertyname == "AJCJLV")
            {
                return this.AJDiff >= 0;
            }
            if (propertyname == "PJDCBXE")
            {
                return this.PJDCBXE >= this.SellerPerformanceStandard.PJDCBXE;
            }
            if (propertyname == "TCCXSLV")
            {
                return this.TCCXSLV >= this.SellerPerformanceStandard.TCCXSLV;
            }
            if (propertyname == "YXZHCXSLV")
            {
                return this.YXZHCXSLV >= this.SellerPerformanceStandard.YXZHCXSLV;
            }
            if (propertyname == "PJDCZHE")
            {
                return this.PJDCZHE >= this.SellerPerformanceStandard.PJDCZHE;
            }
            if (propertyname == "XCYBSXLV")
            {
                return this.YBDiff >= 0;
            }
            if (propertyname == "ECYYCGLV")
            {
                return this.ECYYCGLV >= this.SellerPerformanceStandard.ECYYCGLV;
            }
            if (propertyname == "LKHTJCGLV")
            {
                return this.LKHTJCGLV >= this.SellerPerformanceStandard.LKHTJCGLV;
            }
            return null;
        }
        #endregion



        public int Year { get; set; }
        public int Month { get; set; }
        public int Day { get; set; }
        public Store Store { get; set; }
        public CommonSellerKpi.CommonSellerKpiMonthConfig SellerKpiMonthConfig { get; set; }
        public SellerPerformanceStandard SellerPerformanceStandard { get; set; }
        /// <summary>
        /// 已经确认过月初计划
        /// </summary>
        public virtual bool IsCarKpiMonthConfigConfirmed
        {
            get
            {
                return this.SellerKpiMonthConfig != null && SellerKpiMonthConfig.IsConfirmed;
            }
        }

        /// <summary>
        /// 本月执行天数
        /// </summary>
        public int Days
        {
            get { return DateTime.DaysInMonth(Year, Month); }
        }

        /// <summary>
        /// 时间进度
        /// </summary>
        public decimal RateOfTime
        {
            get { return (decimal)Day * 100 / (decimal)Days; }
        }

        /// <summary>
        /// 月初尚存意向客户数
        /// </summary>
        public virtual int LastMonthPotentialClient
        {
            get
            {
                return 0;
            }
        }
        /// <summary>
        /// 月初尚存意向客户数
        /// </summary>
        [Export("月初尚存意向客户数")]
        public virtual int YCSCYXKHS
        {
            get
            {
                return LastMonthPotentialClient;
            }
        }

        /// <summary>
        /// 累计订单数
        /// </summary>
        [Export("订单数")]
        public virtual int OrderCount
        {
            get
            {
                return 0;
            }
        } 
        /// <summary>
        /// 累计交车数
        /// </summary>
        [Export("交车数")]
        public virtual int SaleCount
        {
            get
            {
                return 0;
            }
        }
        /// <summary>
        /// 当   月   累    计   交车   数
        /// </summary>
        public virtual int JCS
        {
            get
            {
                return SaleCount;
            }
        }
        /// <summary>
        /// 销售目标
        /// </summary>
        [Export("销售目标")]
        public virtual int SaleTarget
        {
            get
            {
                return 0;
            }
        }
        /// <summary>
        /// 销量进度
        /// </summary>
        [Export("销量进度", Format = "{0}%")]
        public virtual decimal SaleRate
        {
            get
            {
                if (SaleTarget == 0)
                {
                    return 0;
                }
                return (decimal)SaleCount * 100 / (decimal)SaleTarget;
            }
        }
        /// <summary>
        /// 首   次   来   店  客   户   登   记   数
        /// </summary>
        [Export("首次来店客户登记数")]
        public virtual int SCLDKHDJS
        {
            get { return 0; }
        }

        /// <summary>
        /// 首   次   来   店  接   待   批   次
        /// </summary>
        [Export("首次来店接待批次")]
        public virtual int LDJDPC
        {
            get { return 0; }
        }

        /// <summary>
        /// 首次来店登记率
        /// </summary>
        [Export("首次来店登记率", Format = "{0}%")]
        public virtual decimal SCLDDJLV
        {
            get
            {

                //首   次   来   店  客   户   登   记   数
                var value1 = SCLDKHDJS;
                //首   次   来   店  接   待   批   次
                var value2 = LDJDPC;
                if (value2 == 0)
                {
                    return 0;
                }
                return (decimal)value1 * 100 / (decimal)value2;
            }
        }

        /// <summary>
        /// 试  驾  邀  请  书  填  写  数
        /// </summary>
        [Export("试驾邀请书填写数")]
        public virtual int SJYQSTXS
        {
            get
            {
                return 0;
            }
        }
        /// <summary>
        /// 试乘试驾率
        /// </summary>
        [Export("试乘试驾率", Format = "{0}%")]
        public virtual decimal SCSJLV
        {
            get
            {

                //试  驾  邀  请  书  填  写  数
                var value1 = SJYQSTXS;
                //首   次   来   店  客   户   登   记   数
                var value2 = SCLDKHDJS;
                if (value2 == 0)
                {
                    return 0;
                }
                return (decimal)value1 * 100 / (decimal)value2;
            }
        }
        /// <summary>
        /// 试  驾  客  户   成   交   数
        /// </summary>
        [Export("试驾客户未成交数")]
        public virtual int SJKHCJS
        {
            get
            {
                return 0;
            }
        }

        /// <summary>
        /// 试乘试驾成交率
        /// </summary>
        [Export("试驾未成交率", Format = "{0}%")]
        public virtual decimal SCSJCJLV
        {
            get
            {

                //试  驾  客  户   成   交   数
                var value1 = SJKHCJS;
                //试  驾  邀  请  书  填  写  数
                var value2 = SJYQSTXS;
                if (value2 == 0)
                {
                    return 0;
                }
                return (decimal)value1 * 100 / (decimal)value2;
            }
        }
        /// <summary>
        /// 登记客户成交率
        /// </summary>
        [Export("登记客户成交率", Format = "{0}%")]
        public virtual decimal DJKHCJLV
        {
            get
            {

                //当   月   累    计   交车   数
                var value1 = JCS;
                //首   次   来   店  客   户   登   记   数
                var value2 = SCLDKHDJS;
                if (value2 == 0)
                {
                    return 0;
                }
                return (decimal)value1 * 100 / (decimal)value2;
            }
        }
        /// <summary>
        /// 上月遗留客户新增订单
        /// </summary>
        [Export("上月遗留客户新增订单")]
        public virtual int SYYLKHXZDD
        {
            get
            {
                return 0;
            }
        }
        /// <summary>
        /// 上月客户转化率
        /// </summary>
        [Export("上月客户转化率", Format = "{0}%")]
        public virtual decimal SYKHZHLV
        {
            get
            {

                //上月遗留客户新增订单
                var value1 = SYYLKHXZDD;
                //月初尚存意向客户数
                var value2 = LastMonthPotentialClient;
                if (value2 == 0)
                {
                    return 0;
                }
                return (decimal)value1 * 100 / (decimal)value2;
            }
        }
        /// <summary>
        /// 超   限   价   格   成   交   数
        /// </summary>
        [Export("超限价格成交数")]
        public virtual int CXJGCJS
        {
            get
            {
                return 0;
            }
        }
        /// <summary>
        /// 超限价格成交率
        /// </summary>
        [Export("超限价格成交率", Format = "{0}%")]
        public virtual decimal CXJGCJLV
        {
            get
            {

                //超   限   价   格   成   交   数
                var value1 = CXJGCJS;
                //当   月   累    计   交车   数
                var value2 = JCS;
                if (value2 == 0)
                {
                    return 0;
                }
                return (decimal)value1 * 100 / (decimal)value2;
            }
        }

        /// <summary>
        /// 首   次   来   店     登   记   数  目  标
        /// </summary>
        [Export("首次来店登记数目标")]
        public virtual int SCLDDJMB
        {
            get
            {
                return 0;
            }
        }
        /// <summary>
        /// 有效  A   卡   建卡   数
        /// </summary>
        [Export("有效A卡建卡数")]
        public virtual decimal YXAKJKS
        {
            get
            {
                return 0;
            }
        }
        /// <summary>
        /// 商   谈   明   细   表   填   写   数
        /// </summary>
        [Export("商谈明细表填写数")]
        public virtual decimal STMXBTXS
        {
            get
            {
                return 0;
            }
        }


        /// <summary>
        /// 二 手 车 评 估 数
        /// </summary>
        [Export("二手车评估数")]
        public virtual decimal ESCPGS
        {
            get
            {
                return 0;
            }
        }
        /// <summary>
        /// 置 换 成 交 数
        /// </summary>
        [Export("置换成交数")]
        public virtual decimal ZHCJS
        {
            get
            {
                return 0;
            }
        }
        /// <summary>
        /// 按 揭 成 交 数
        /// </summary>
        [Export("按揭成交数")]
        public virtual decimal AJCJS
        {
            get
            {
                return 0;
            }
        }
        /// <summary>
        /// 当月客户新增订单数
        /// </summary>
        [Export("当月客户新增订单数")]
        public virtual decimal DYKHXZDD
        {
            get
            {
                return 0;
            }
        }
        /// <summary>
        /// 新   车   保   险   投   保  数
        /// </summary>
        [Export("新车保险投保数")]
        public virtual decimal XCBXTBS
        {
            get
            {
                return 0;
            }
        }
        /// <summary>
        /// 保       险       销       售       总      额
        /// </summary>
        [Export("保险销售额")]
        public virtual decimal BXXSE
        {
            get
            {
                return 0;
            }
        }
        /// <summary>
        /// 套   餐    车 销   售  数   量
        /// </summary>
        [Export("套餐车销售数量")]
        public virtual decimal TCCXSSL
        {
            get
            {
                return 0;
            }
        }
        /// <summary>
        /// 有   效  装 潢   车   销   售   数   量
        /// </summary>
        [Export("有效装潢车销售数量")]
        public virtual decimal YXZHCXSSL
        {
            get
            {
                return 0;
            }
        }
        /// <summary>
        /// 装   潢   车     装     潢     销     售          额    （万）
        /// </summary>
        [Export("装潢销售额")]
        public virtual decimal ZHCZHXSE
        {
            get
            {
                return 0;
            }
        }
        /// <summary>
        /// 新 车 延 保 数
        /// </summary>
        [Export("新车延保数")]
        public virtual decimal XCYBS
        {
            get
            {
                return 0;
            }
        }
        /// <summary>
        /// 二次   成  功   邀   约   客  户  数
        /// </summary>
        [Export("二次成功邀约客户数")]
        public virtual decimal ECCGYYKHS
        {
            get
            {
                return 0;
            }
        }
        /// <summary>
        /// 当   月      老 客   户   推   荐  成   交 数
        /// </summary>
        [Export("老客户推荐成交数")]
        public virtual decimal DYLKHTJCJS
        {
            get
            {
                return 0;
            }
        }
        /// <summary>
        /// 首次来店接待目标
        /// </summary>
        [Export("首次来电接待目标")]
        public virtual decimal SCLDJDMB
        {
            get
            {
                return 0;
            }
        }
        /// <summary>
        /// 销量完成进度
        /// </summary>
        public virtual decimal XLWCD
        {
            get
            {
                return SaleRate;
                //if (SaleTarget == 0)
                //{
                //    return 100;
                //}

                //return (this.DYKHXZDD + JCS) * 100 / SaleTarget;
            }
        }
        /// <summary>
        /// 销量进度差
        /// </summary>
        [Export("销量进度差", Format = "{0}%")]
        public virtual decimal XLJDC
        {
            get
            {
                if (SaleTarget == 0)
                {
                    return 0;
                }
                return XLWCD - RateOfTime;
            }
        }
        /// <summary>
        /// 来店批次完成进度
        /// </summary>
        [Export("来店批次完成进度")]
        public virtual decimal LDPCWCD
        {
            get
            {
                if (SCLDJDMB == 0)
                {
                    return 0;
                }
                return LDJDPC * 100 / SCLDJDMB;
            }
        }

        /// <summary>
        /// 来电批次完成进度
        /// </summary>
        public virtual decimal LDHPCWCD
        {
            get
            {
                if (SCLDHJDMB == 0)
                {
                    return 0;
                }
                return LDJDPC * 100 / SCLDHJDMB;
            }
        }

        public virtual decimal SCLDHJDMB
        {
            get {
                return 0;
            }
        }

        /// <summary>
        /// 来店批次差
        /// </summary>
        [Export("来店批次差")]
        public virtual decimal LDPCDiff
        {
            get
            {
                if (SCLDJDMB == 0)
                {
                    return 0;
                }
                return LDJDPC - SCLDJDMB;
            }
        }
        /// <summary>
        /// 来店批次进度差
        /// </summary>
        [Export("来店批次进度差", Format = "{0}%")]
        public virtual decimal LDPCJDC
        {
            get
            {
                if (SCLDJDMB == 0)
                {
                    return 0;
                }
                return LDPCWCD - RateOfTime;
            }
        }

        public virtual decimal LDHPCJDC
        {
            get
            {
                if (SCLDHJDMB == 0)
                {
                    return 0;
                }
                return LDHPCWCD - RateOfTime;
            }
        }

        /// <summary>
        /// 当月登记客户完成进度
        /// </summary>
        [Export("当月登记客户完成进度", Format = "{0}%")]
        public virtual decimal DJKHWCJD
        {
            get
            {
                if (SCLDDJMB == 0)
                {
                    return 0;
                }
                return (decimal)SCLDKHDJS * 100 / (decimal)SCLDDJMB;
            }
        }
        /// <summary>
        /// 登记客户进度率差
        /// </summary>
        [Export("登记客户进度率差", Format = "{0}%")]
        public virtual decimal DJKHJDC
        {
            get
            {
                return DJKHWCJD - RateOfTime;
            }
        }
        /// <summary>
        /// A   卡需 求 完整分 析 率
        /// </summary>
        [Export("A卡需求完整分析率", Format = "{0}%")]
        public virtual decimal AKXQWZFXLV
        {
            get
            {
                if (SCLDKHDJS == 0)
                {
                    return 0;
                }
                return (decimal)YXAKJKS * 100 / (decimal)SCLDKHDJS;
            }
        }
        /// <summary>
        /// 商 谈 明 细 表 填 写 率
        /// </summary>
        [Export("商谈明细表填写率", Format = "{0}%")]
        public virtual decimal STMXBTXLV
        {
            get
            {
                if (SCLDKHDJS == 0)
                {
                    return 0;
                }
                return (decimal)STMXBTXS * 100 / (decimal)SCLDKHDJS;
            }
        }
        /// <summary>
        /// 当月登 记 客 户 成 交 率
        /// </summary>
        [Export("当月登记客户成交率", Format = "{0}%")]
        public virtual decimal DYDJKHCJLV
        {
            get
            {
                if (SCLDKHDJS == 0)
                {
                    return 0;
                }
                return (decimal)JCS * 100 / (decimal)SCLDKHDJS;
            }
        }
        /// <summary>
        /// 订单交车转化率
        /// </summary>
        [Export("订单交车转化率", Format = "{0}%")]
        public virtual decimal DDJCZHLV
        {
            get
            {
                if (OrderCount == 0)
                {
                    return 0;
                }
                return (decimal)JCS * 100 / (decimal)OrderCount;
            }
        }
        /// <summary>
        /// 当月二手车评估率
        /// </summary>
        [Export("二手车评估率", Format = "{0}%")]
        public virtual decimal ESCPGLV
        {
            get
            {
                if (SCLDKHDJS == 0)
                {
                    return 0;
                }
                return (decimal)ESCPGS * 100 / (decimal)SCLDKHDJS;
            }
        }
        /// <summary>
        /// 当月置换率
        /// </summary>
        [Export("当月置换率", Format = "{0}%")]
        public virtual decimal ZHLV
        {
            get
            {
                if (JCS == 0)
                {
                    return 0;
                }
                return (decimal)ZHCJS * 100 / (decimal)JCS;
            }
        }

        /// <summary>
        /// 当月置换率差异
        /// </summary>
        [Export("当月置换率差异", Format = "{0}%")]
        public virtual decimal ZHLVDiff
        {
            get
            {
                if (JCS == 0)
                {
                    return 0;
                }
                return ZHLV - this.SellerPerformanceStandard.ZHLV;
            }
        }
        /// <summary>
        /// 当 月 保 险 率
        /// </summary>
        [Export("当月保险率", Format = "{0}%")]
        public virtual decimal BXLV
        {
            get
            {
                if (JCS == 0)
                {
                    return 0;
                }
                return (decimal)XCBXTBS * 100 / (decimal)JCS;
            }
        }

        /// <summary>
        /// 当 月 保 险 率差异
        /// </summary>
        [Export("当月保险率差异", Format = "{0}%")]
        public virtual decimal BXLVDiff
        {
            get
            {
                if (JCS == 0)
                {
                    return 0;
                }
                return BXLV - this.SellerPerformanceStandard.BXLV;
            }
        }
        /// <summary>
        /// 当月按揭成交率
        /// </summary>
        [Export("当月按揭成交率", Format = "{0}%")]
        public virtual decimal AJCJLV
        {
            get
            {
                if (JCS == 0)
                {
                    return 0;
                }
                return (decimal)AJCJS * 100 / (decimal)JCS;
            }
        }
        /// <summary>
        /// 按揭率差
        /// </summary>
        public virtual decimal AJDiff
        {
            get
            {
                if (JCS == 0)
                {
                    return 0;
                }
                return AJCJLV - this.SellerPerformanceStandard.AJCJLV;
            }
        }
        /// <summary>
        /// 平     均     单      车     保     险     额              (万）
        /// </summary>
        [Export("平均单车保险额")]
        public virtual decimal PJDCBXE
        {
            get
            {
                if (XCBXTBS == 0)
                {
                    return 0;
                }
                return (decimal)BXXSE / (decimal)XCBXTBS;
            }
        }
        /// <summary>
        /// 平       均       单       车       装       潢       额                 （万）
        /// </summary>
        [Export("平均单车装潢额")]
        public virtual decimal PJDCZHE
        {
            get
            {
                if (YXZHCXSSL == 0)
                {
                    return 0;
                }
                return (decimal)ZHCZHXSE  / (decimal)YXZHCXSSL;
            }
        }
        /// <summary>
        /// 套餐车 销 售 率
        /// </summary>
        [Export("套餐车销售率", Format = "{0}%")]
        public virtual decimal TCCXSLV
        {
            get
            {
                if (JCS == 0)
                {
                    return 0;
                }
                return (decimal)TCCXSSL * 100 / (decimal)JCS;
            }
        }
        /// <summary>
        /// 有效装潢车销售率
        /// </summary>
        [Export("有效装潢车销售率", Format = "{0}%")]
        public virtual decimal YXZHCXSLV
        {
            get
            {
                if (JCS == 0)
                {
                    return 0;
                }
                return (decimal)YXZHCXSSL * 100 / (decimal)JCS;
            }
        }
        /// <summary>
        /// 新车延保实现率
        /// </summary>
        [Export("新车延保实现率", Format = "{0}%")]
        public virtual decimal XCYBSXLV
        {
            get
            {
                if (JCS == 0)
                {
                    return 0;
                }
                return (decimal)XCYBS * 100 / (decimal)JCS;
            }
        }
        public virtual decimal YBDiff
        {
            get
            {
                if (JCS == 0)
                {
                    return 0;
                }
                return XCYBSXLV - this.SellerPerformanceStandard.XCYBSXLV;
            }
        }
        /// <summary>
        /// 二 次  邀 约 成 功 率
        /// </summary>
        [Export("二次邀约成功率", Format = "{0}%")]
        public virtual decimal ECYYCGLV
        {
            get
            {
                if (SCLDKHDJS == 0)
                {
                    return 0;
                }
                return (decimal)ECCGYYKHS * 100 / (decimal)SCLDKHDJS;
            }
        }
        /// <summary>
        /// 老 客 户  推 荐 成 功 率
        /// </summary>
        [Export("老客户推荐成功率", Format = "{0}%")]
        public virtual decimal LKHTJCGLV
        {
            get
            {
                if (JCS == 0)
                {
                    return 0;
                }
                return (decimal)DYLKHTJCJS * 100 / (decimal)JCS;
            }
        }
    }
}
